﻿<?
include("../config/header.php");
?>
<script type='text/javascript'>
	document.title = '散列/哈希加密解密 —— 在线工具';
</script>
<style>
#p_div{display:none; margin-left:5px;}
</style>
<div class="container">
	<div class="panel panel-primary">
		<div class="panel-heading"><h3 class="panel-title">散列/哈希加密解密</h3></div>
	</div>
	<div class="form-group">
		<label>请把要加密的文字粘贴到下面表单：</label>
		<textarea id="content" name="content" class="form-control" style="width:100%;height:250px;border:1px solid #c5e2f2;overflow:visible;" onfocus="if(jQuery(this).val()=='[要加密的内容放上面，要解密的内容放下面]'){jQuery(this).val('');}" onblur="if(jQuery(this).val()==''){jQuery(this).val('[要加密的内容放上面，要解密的内容放下面]');}"  rows="15">[要加密的内容放上面，要解密的内容放下面]</textarea>
	</div>
	<div class="form-group" align="center">
		<button onclick="Emptyhash()" class="button button-rounded button-flat">清空</button>
		<button onclick="hash('sha1');" class="button button-rounded button-flat">SHA1</button>
		<button onclick="hash('sha224');" class="button button-rounded button-flat-primary">SHA224</button>
		<button onclick="hash('sha256');" class="button button-rounded button-flat-action">SHA256</button>
		<button onclick="hash('sha384');" class="button button-rounded button-flat-highlight">SHA384</button>
		<button onclick="hash('sha512');" class="button button-rounded button-flat-caution">SHA512</button>
		<button onclick="hash('md5');" class="button button-rounded button-flat-royal">MD5</button><br/><br/>
		<button onclick="hash('hmacsha1');" class="button button-rounded button-flat">HmacSHA1</button>
		<button onclick="hash('hmacsha224');" class="button button-rounded button-flat-primary">HmacSHA224</button>
		<button onclick="hash('hmacsha256');" class="button button-rounded button-flat-action">HmacSHA256</button>
		<button onclick="hash('hmacsha384');" class="button button-rounded button-flat-highlight">HmacSHA384</button>
		<button onclick="hash('hmacsha512');" class="button button-rounded button-flat-caution">HmacSHA512</button>
		<button onclick="hash('hmacmd5');" class="button button-rounded button-flat-royal">HmacMD5</button>
	</div>
	<div class="form-group">
		<div id="p_div">密钥：<input type="text" id="pwd" class="pwd"/></div>
	</div>
	<div class="form-group">
		<label>加密结果如下：</label>
		<textarea id="result" name="result" class="form-control" style="width:100%;height:250px;border:1px solid #c5e2f2;overflow:visible;"></textarea>
	</div>
</div>
<script type="text/javascript" src="<?php echo $url;?>content/js/core.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/sha1.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/sha256.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/sha512.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/md5.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-sha1.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-sha224.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-sha256.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-sha384.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-sha512.js"></script>
<script type="text/javascript" src="<?php echo $url;?>content/js/hash/hmac-md5.js"></script>
<script type="text/javascript">
function hash(type) {
	switch (type) {
		case "sha1":
		hide_pwd();
		jQuery("#result").val(CryptoJS.SHA1(jQuery("#content").val()));
		break;
	case "sha224":
		hide_pwd();
		jQuery("#result").val(CryptoJS.SHA224(jQuery("#content").val()));
		break;
	case "sha256":
		hide_pwd();
		jQuery("#result").val(CryptoJS.SHA256(jQuery("#content").val()));
		break;
	case "sha384":
		hide_pwd();
		jQuery("#result").val(CryptoJS.SHA384(jQuery("#content").val()));
		break;
	case "sha512":
		hide_pwd();
		jQuery("#result").val(CryptoJS.SHA512(jQuery("#content").val()));
		break;
	case "md5":
		hide_pwd();
		jQuery("#result").val(CryptoJS.MD5(jQuery("#content").val()));
		break;
	case "hmacsha1":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacSHA1(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	case "hmacsha224":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacSHA224(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	case "hmacsha256":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacSHA256(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	case "hmacsha384":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacSHA384(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	case "hmacsha512":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacSHA512(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	case "hmacmd5":
		show_pwd();
		jQuery("#result").val(CryptoJS.HmacMD5(jQuery("#content").val(), jQuery("#pwd").val()));
		break;
	}
}
function hide_pwd() {
	$("#p_div").hide();
}
function show_pwd(){
	$("#p_div").show();
}
function Emptyhash(){
	jQuery('#content').val('');
	jQuery('#result').val('');
}
</script>
<?php
include("../config/footer.php");
?>